// 类继承语法 Student.prototype.__proto__ = Person.prototype;

/**
 * 分页查询类(请求)
 * @param object (lastRecordId)
 * @param pageSize
 * @param orderType
 * @param orderField
 * @param lastOrderValue
 * @constructor
 */
function Page(object, pageSize, orderType, orderField, lastOrderValue) {
    if (object instanceof Object) {
        pageSize = pageSize || {};
        this.lastRecordId = object.lastRecordId || "";
        this.pageSize = object.pageSize || 10;
        this.orderType = object.orderType || "ASC";
        this.orderField = object.orderField || "id";
        this.lastOrderValue = object.lastOrderValue || "";
        this.keyWords = pageSize.keyWords;
    } else {
        this.lastRecordId = object;
        this.pageSize = pageSize;
        this.orderType = orderType;
        this.orderField = orderField;
        this.lastOrderValue = lastOrderValue;
    }
}

/**
 * 登录类(请求)
 * @param object (mobile)
 * @param password
 * @param regid
 * @param type
 * @constructor
 */
function LoginBean(object, password,regid,type) {
    if (object instanceof Object) {
        this.mobile = object.mobile;
        this.password = object.password;
    } else {
        this.mobile = object;
        this.password = password;
    }
    this.role = 1;
    this.regid = regid;
    this.type = type;
}

/**
 * 注册类(请求)
 * @param object (mobile)
 * @param password
 * @param vfCode
 * @param regid
 * @param type
 * @constructor
 */
function RegisterBean(object, password, vfCode,regid,type) {
    if (object instanceof Object) {
        this.mobile = object.mobile;
        this.password = object.password;
        this.vfCode = object.vfCode;
    } else {
        this.mobile = object;
        this.password = password;
        this.vfCode = vfCode;
    }
    this.role = 1;
    this.regid = regid;
    this.type = type;
}

/**
 * 提交类(请求)
 * @param object
 * @param id
 * @param type
 * @constructor
 */
function ConfigSubmitBean(object, id, type, value) {
    if (object instanceof Object) {
        this.entryKey = object.entryKey;
        this.id = object.id;
        this.type = object.type;
        this.value = object.value;
    } else {
        this.entryKey = object;
        this.id = id;
        this.type = type;
        this.value = value;

    }
}

/**
 * 结果类
 * @param object(code)
 * @param msg
 * @param data
 * @constructor
 */
function Result(object, msg, data) {
    if (object instanceof Object) {
        this.code = object.state;
        this.msg = object.message;
        this.data = object.returnData;
    } else {
        this.code = object;
        this.msg = msg;
        this.data = data;
    }
    if (!this.msg && typeof this.data === 'string') {
        this.msg = this.data
    }
}

/**
 * 选择器类(结果)
 * @param object (text)
 * @param value
 * @constructor
 */
function Picker(object, value) {
    if (object instanceof Object) {
        this.text = object.text;
        this.value = object.value;
    } else {
        this.text = object;
        this.value = value;
    }
}

/**
 * 收藏类(结果)
 * @param object(appUserId)
 * @param status
 * @param subjectId
 * @param type
 * @constructor
 */
function UserInFavour(object, status, subjectId, type) {
    if (object instanceof Object) {
        this.appUserId = object.appUserId;
        this.status = object.status;
        this.subjectId = object.subjectId;
        this.type = object.type;
    } else {
        this.appUserId = object;
        this.status = status;
        this.subjectId = subjectId;
        this.type = type;
    }
}

/**
 * 配置类(结果)
 * @param object(id)
 * @param name
 * @param type
 * @param isRequired
 * @param entryKey
 * @param configValue
 * @param values
 * @constructor
 */
function ConfigBean(object, name, type, isRequired, entryKey, configValue, values, remark) {
    if (object instanceof Object) {
        this.id = object.id;
        this.name = object.name;
        this.type = object.type;
        this.isRequired = object.isRequired && object.isRequired !== "0" ? "require" : "optional";
        this.entryKey = object.entryKey;
        this.sort = null;
        this.delStatus = null;
        this.updateTime = null;
        this.createTime = null;
        this.configValue = object.configValue || "";
        this.remark = object.remark || '';
        values = object.values;
    } else {
        this.id = object;
        this.name = name;
        this.type = type;
        this.isRequired = isRequired ? "require" : "optional";
        this.entryKey = entryKey;
        this.sort = null;
        this.delStatus = null;
        this.updateTime = null;
        this.createTime = null;
        this.configValue = configValue || "";
        this.remark = remark || '';
    }

    if (this.remark) {
        this.js_show = 'js_show';
    }

    this.select = "select";
    var pickers = [];
    if (this.type == 2) {
        values = [
            {id: "1", value: "是"},
            {id: "0", value: "否"}
        ];
    }
    for (var i in values) {
        if (this.configValue == values[i].id) {
            this.configName = values[i].value;
            this.select = "selected";
        }
        pickers.push(new Picker(values[i].value, values[i].id));
    }
    this.values = pickers;
}

/**
 * 匹配结果类(结果)
 * @param object(id)
 * @param policyId
 * @param appUserId
 * @param policyTitle
 * @param score
 * @constructor
 */
function MatchBean(object, policyId, appUserId, policyTitle, score) {
    var color = ["none", "red", "yellow", "green"];
    if (object instanceof Object) {
        this.id = object.id;
        this.policyId = object.policyId;
        this.appUserId = object.appUserId;
        this.policyTitle = object.policyTitle;
        this.score = Math.floor(object.score * 100);
    } else {
        this.id = object;
        this.policyId = policyId;
        this.appUserId = appUserId;
        this.policyTitle = policyTitle;
        this.score = Math.floor(score * 100);
    }
    this.bg = Math.floor(this.score / 5) * 5;
    if (this.score === 100) this.score = 99;
    this.ten = Math.floor(this.score / 10);
    this.one = this.score % 10;
}

//(value = "移动端用户信息")
function AppUserBean(id, fullName, mobileNumber, headImg, password, userRole, registerDate, loginCount, token, loginTime, tokenRefreshTime, delStatus, company, email) {
    if (id instanceof Object) {
        //(notes = "主键")
        this.id = id.id || "";
        //(notes = "姓名")
        this.fullName = id.fullName || "";
        this.email = id.email;
        //(notes = "手机号")
        this.mobileNumber = id.mobileNumber || "";
        //(notes = "头像")
        this.headImg = id.headImg || '';
        //(notes = "密码")
        this.password = id.password || "";
        //(notes = "用户角色=obj.//(notes = "用户角色||1-普通用户，接单员-2")
        this.userRole = id.userRole;
        //(notes = "注册日期")
        this.registerDate = id.registerDate || "";
        //(notes = "登录次数")
        this.loginCount = id.loginCount || "";
        //(notes = "认证token")
        this.token = id.token;
        //(notes = "登录时间")
        this.loginTime = id.loginTime || "";
        //(notes = "token更新时间")
        this.tokenRefreshTime = id.tokenRefreshTime || "";
        //(notes = "删除状态")
        this.delStatus = id.delStatus || "";
        this.company = id.company || "";
    } else {
        //(notes = "主键")
        this.id = id || "";
        //(notes = "姓名")
        this.fullName = fullName || "";
        //(notes = "手机号")
        this.mobileNumber = mobileNumber || "";
        //(notes = "头像")
        this.headImg = headImg || '';
        //(notes = "密码")
        this.password = password || "";
        //(notes = "用户角色=obj.//(notes = "用户角色||1-普通用户，接单员-2")
        this.userRole = userRole;
        //(notes = "注册日期")
        this.registerDate = registerDate || "";
        //(notes = "登录次数")
        this.loginCount = loginCount || "";
        //(notes = "认证token")
        this.token = token;
        //(notes = "登录时间")
        this.loginTime = loginTime || "";
        //(notes = "token更新时间")
        this.tokenRefreshTime = tokenRefreshTime || "";
        //(notes = "删除状态")
        this.delStatus = delStatus || "";
        this.company = company || "";
        this.email = id.email;
    }
    var idStr = (+id + 10000) + "";
    this.serviceNumber = 'A' + idStr.slice(idStr.length - 4, idStr.length);
}

//(value = "咨询订单")
function ConsultOrder(obj) {
    obj = obj || {};
    return {
        //(notes = "主键")
        id: obj.id || "",
        //(notes = "政策id")
        policyId: obj.policyId || Random.natural(1, 10000),
        //(notes = "用户id")
        appUserId: obj.appUserId || Random.natural(1, 10000),
        //(notes = "匹配结果id")
        matchResultId: obj.matchResultId || Random.natural(1, 10000),
        //(notes = "接单人id")
        serverId: obj.serverId || Random.natural(1, 10000),
        //(notes = "订单状态：0-待咨询，1-咨询中，2-已完成，3-已取消")
        status: obj.status || Random.natural(0, 3),
        //(notes = "删除状态")
        delStatus: obj.delStatus || Random.natural(0, 1),
        //(notes = "数据更新时间")
        updateTime: obj.updateTime || Random.datetime(),
        //(notes = "咨询时间")
        createTime: obj.createTime || Random.datetime(),
        //(notes = "政策标题")
        policyTitle: obj.policyTitle || Random.ctitle(3, 7),
        //(notes = "下单人")
        appUserName: obj.appUserName || Random.cname(),
        //(notes = "接单人")
        serverUserName: obj.serverUserName || Random.cname()
    };
}

//(value = "时势管理")
function EventBean(obj) {
    //(notes = "主键")
    this.id = obj.id || "";
    this.//(notes = "标题")
        title = obj.title || "";
    this.//(notes = "查阅人数")
        viewCount = obj.viewCount || "";
    this.//(notes = "封面图")
        coverImgs = obj.coverImgs || [];
    this.//(notes = "内容")
        content = obj.content || "";
    this.//(notes = "删除状态")
        delStatus = obj.delStatus || "";
    this.//(notes = "数据更新时间")
        updateTime = obj.updateTime || "";
    this.updateDate = this.updateTime.slice(0, 10);
    this.//(notes = "数据添加时间")
        createTime = obj.createTime || "";
    this.author = obj.author || '';

}

//(value = "攻略表")
function GuideBean(obj) {
    //(notes = "主键")
    this.id = obj.id;
    this.//(notes = "关联政策id")
        policyId = obj.policyId;
    this.//(notes = "标题")
        title = obj.title;
    this.//(notes = "查阅人数")
        viewCount = obj.viewCount;
    this.//(notes = "收藏人数")
        favourCount = obj.favourCount || 0;
    this.//(notes = "封面图")
        coverImg = obj.coverImg;
    this.//(notes = "视频")
        video = obj.video;
    this.//(notes = "视频长度")
        videoLength = obj.videoLength;
    this.//(notes = "作者")
        author = obj.author;
    this.//(notes = "内容")
        content = obj.content;
    this.//(notes = "删除状态")
        delStatus = obj.delStatus;
    this.//(notes = "数据更新时间")
        updateTime = obj.updateTime;
    this.updateDate = this.updateTime.slice(0, 10);
    this.//(notes = "数据添加时间")
        createTime = obj.createTime;
    this.favoured = obj.favoured;
}

//(value = "首页资讯")
function HomeNews(obj) {
    return {
        //(notes = "主键")
        id: obj.id || Random.natural(1, 10000),
        //(notes = "标题")
        title: obj.title || Random.ctitle(3, 7),
        //(notes = "内容")
        content: obj.content || Random.cparagraph(3, 7),
        //(notes = "封面图")
        coverImg: obj.coverImg || Random.dataImage(),
        //(notes = "创建时间")
        createTime: obj.createTime || Random.datetime(),
        //(notes = "修改时间")
        updateTime: obj.updateTime || Random.datetime(),
        //(notes = "删除状态，0可用，1已删除")
        delStatus: obj.delStatus || Random.natural(0, 1)
    };
}

function HomeInfo(obj) {
    return {
        matchAmount: obj.matchAmount || 0,
        projectCount: obj.projectCount || 0,
        companyCount: obj.companyCount || 0
    };
}

//(value = "政策匹配项")
function MatchConfig(obj) {
    return {
        //(notes = "主键")
        id: obj.id || Random.natural(1, 10000),
        //(notes = "匹配项目名称")
        name: obj.name || Random.ctitle(2, 4),
//(notes = "1:obj.//(notes = "1||数值类型，2:boolean类型，3:下拉选，4:文本类型")
        type: obj.type || Random.natural(1, 4),
        //(notes = "是否必填，0选填，1必填")
        isRequired: obj.isRequired || Random.natural(0, 1),
        //(notes = "匹配项key")
        entryKey: obj.entryKey || Random.string("lower", 1, 32),
        //(notes = "显示排序")
        sort: obj.sort || Random.natural(1, 10000),
//(notes = "0:obj.//(notes = "0||删除;1:正常")
        delStatus: obj.delStatus || Random.natural(0, 1),
        //(notes = "数据更新时间")
        updateTime: obj.updateTime || Random.datetime(),
        //(notes = "数据添加时间")
        createTime: obj.createTime || Random.datetime()
    };
}

//(value = "政策信息")
function PolicyBean(obj) {
    //(notes = "主键")
    this.id = obj.id || "";
    //(notes = "标题")
    this.title = obj.title || "";
    this.author = obj.author || "";
    //(notes = "查阅人数")
    this.viewCount = obj.viewCount || "";
    //(notes = "封面图")
    this.coverImg = obj.coverImg || "";
    //(notes = "内容")
    this.content = obj.content || "";
    //(notes = "附件")
    this.attachment = obj.attachment || "";
    //(notes = "删除状态")
    this.delStatus = obj.delStatus || "";
    //(notes = "数据更新时间")
    this.updateTime = obj.updateTime || "";
    this.updateDate = this.updateTime.slice(0, 10);
    //(notes = "数据添加时间")
    this.createTime = obj.createTime || "";
    this.attachmentList = obj.attachmentList || [];
}